var SelectSalesOrder = 
'<div class="modal" id="SelectSalesOrder" tabindex="-1" role="dialog" aria-hidden="true">'+
	'<div class="modal-dialog" style="width: 800px !important;">'+
		'<div class="modal-content">'+
			'<div class="modal-header">'+
				'<button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>'+
				'<h4 class="modal-title">选择销售订单</h4>'+
				'<div class="form-box2">'+
					'<div class="have-ipt-box">'+
						'<label class="ipt-label" for="">开始日期：</label>'+
						'<input readonly="readonly" class="ipt-self4" type="text" id="startTime_s" value="" />'+
					'</div>'+
					'<div class="have-ipt-box">'+
						'<label class="ipt-label" for="">结束日期：</label>'+
						'<input readonly="readonly" class="ipt-self4" type="text" id="endTime_s" value="" />'+
					'</div>'+
					'<div class="have-ipt-box">'+
						'<label class="ipt-label" for="">订单状态：</label>'+
						'<select class="ipt-self2" id="status_s">'+
							'<option value="">请选择</option>'+
							'<option value="001">启用</option>'+
							'<option value="002">已确定</option>'+
						'</select>'+
					'</div>'+
					'<div class="form-btn-box form-btn-box2">'+
						'<button class="btn-blue" id="salesOrder-selectBtn">'+
							'<img src="../img/btn-icon/search.png"/>'+
							'<span>查询</span>'+
						'</button>'+
						'<button class="btn-green" id="salesOrder-closeBtn">'+
							'<img src="../img/btn-icon/close.png"/>'+
							'<span>关闭</span>'+
						'</button>'+
					'</div>'+
					'<table id="tableSalesOrder"></table>'+
				'</div>'+
			'</div>'+
		'</div>'+
	'</div>'+
'</div>';
$('body').append(SelectSalesOrder);
$("#tableSalesOrder").bootstrapTable({ // 对应table标签的id
	//url: DOMAIN+'/v1/salesOrder'+isLogin,
	method: 'get',
	cache: false,
	striped: true,
	pagination: true,
	pageSize: 5,
	pageNumber: 1,
	pageList: [5, 10],
	search: false,
	showColumns: false, 
	clickToSelect: true,
	queryParams: queryParams,
	smartDisplay: false,
	columns: [{
        checkbox: true
	},{
			field: 'id',
			title: "id",
			align: "center",
			valign: "middle",
			visible: false
		},{
			field: 'orderNo',
			title: "订单号",
			align: "center",
			valign: "middle"
		},{
			field: 'customerName',
			title: "客户名称",
			align: "center",
			valign: "middle"
		}, {
			field: "statusName",
			title: "订单状态",
			align: "center",
			valign: "middle"
		}],	
	onDblClickRow: function (row) {
		selectSalesOrder(row);
		//模拟关闭弹框
		  $('#SelectSalesOrder').click();
	},
	formatNoMatches: function() {
		return '没有找到匹配的记录';
	}
});
function queryParams(params) {
	params.warehouseFlag = "TRUE";
	return params;
};

//查询
$("#salesOrder-selectBtn").click(function(){
	//新查询参数
	function queryParamNew(params) {
		var params = {};
		params.warehouseFlag = "TRUE";
		params.startTime = $("#startTime_s").val();
		params.endTime = $("#endTime_s").val();
		params.status = $("#status_s option:checked").val();
		return params;
	};
	var url =DOMAIN+'/v1/salesOrder'+isLogin;
	$('#tableSalesOrder').bootstrapTable(
			'refreshOptions',
			{
				url: url,
				//查询参数
				queryParams: queryParamNew
			}
		);
	
})

//关闭
$("#salesOrder-closeBtn").click(function(){
	$('#SelectSalesOrder').click();
})

	//打开选择框时查询
	$('#SelectSalesOrder').on('shown.bs.modal', function () {
		$('#startTime_s').val("");
		$('#endTime_s').val("");
		$('#startTime_s').datetimepicker({
			minView: "month",
			language: 'zh-CN',
			format: 'yyyy-mm-dd',
			todayBtn: 1,
			autoclose: true
		});
		$('#endTime_s').datetimepicker({
			minView: "month",
			language: 'zh-CN',
			format: 'yyyy-mm-dd',
			todayBtn: 1,
			autoclose: true
		});
		$('#tableSalesOrder').bootstrapTable(
			'refreshOptions',
			{
				url: DOMAIN+'/v1/salesOrder'+isLogin,
				queryParams: {"warehouseFlag":"TRUE"}
			}
		);
	
	})